import allure
import pytest

from base.apiutil import RequestBase
from common.connection import ConnectMysql
from common.readyaml import ReadYamlData, get_testcase_yaml
from common.recordlog import logs



# @pytest.fixture(scope='session', autouse=True)
# @allure.story("登录")
# def system_login():
#     try:
#         api_info = get_testcase_yaml('./data/login.yaml')
#         RequestBase().specification_yaml(api_info[0][0], api_info[0][1])
#     except Exception as e:
#         logs.error(f'登录接口出现异常，导致后续接口无法继续运行，请检查程序！，{e}')
#         exit()
@pytest.fixture(scope="session", autouse=True)
def clear_yaml_data():
    """清除yaml数据"""
    ReadYamlData().clear_yaml_data()

# @pytest.fixture(scope="session", autouse=True)
# def sql():
#     """sql语句"""
#     sql = 'SELECT * FROM yonghu'
#     ConnectMysql().query(sql)



@pytest.fixture(scope="session", autouse=True)
def fixture_test(request):
    """前后置处理"""
    # print('开始执行')
    logs.info('-------------接口测试开始---------------')
    yield
    # print('执行结束')
    logs.info('-------------接口测试结束---------------')
